From: Giovanni Campagna Date: Tue, 17 Jul 2012 17:27:43 +0000 (+0200) Subject: Panel: fix finding leftmost and rightmost buttons X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~6298 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=d9c3b83d1ed4e5b04d4ef36e383b206203d5370d;p=gnome-shell.git Panel: fix finding leftmost and rightmost buttons Previous code would access the array element before checking that the index was within bounds, and therefore cause a TypeError. It wasn't noticed earlier because at least one visible children is in each panel box in all session modes. https://bugzilla.gnome.org/show_bug.cgi?id=619955 --- diff --git a/js/ui/panel.js b/js/ui/panel.js index c969381af..648a67790 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -753,10 +753,11 @@ const PanelCorner = new Lang.Class({ return null; // Start at the back and work backward - let index = children.length - 1; - while (!children[index].visible && index >= 0) - index--; - + let index; + for (index = children.length - 1; index >= 0; index--) { + if (children[index].visible) + break; + } if (index < 0) return null; @@ -777,10 +778,11 @@ const PanelCorner = new Lang.Class({ return null; // Start at the front and work forward - let index = 0; - while (!children[index].visible && index < children.length) - index++; - + let index; + for (index = 0; index < children.length; index++) { + if (children[index].visible) + break; + } if (index == children.length) return null;